package com.qianya.system.manage.web.login.controller;

import com.qianya.system.manage.web.login.model.LoginOrganization;
import com.qianya.system.manage.web.login.service.ILoginOrganizationService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.BeanUtils;
import com.qianya.model.common.CommonResult;
import com.qianya.model.pojo.login.qo.LoginOrganizationQO;
import com.qianya.model.pojo.login.vo.LoginOrganizationVO;
import javax.servlet.http.HttpServletRequest;
    import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * 机构 前端控制器
    * </p>
*
* @author lhl
* @since 2020-07-02
*/
    @RestController
@RequestMapping("/login-organization")
@Api(value = "LoginOrganizationController", tags = "机构接口")
@Slf4j
public class LoginOrganizationController {

    private Logger logger = LoggerFactory.getLogger(LoginOrganizationController.class);

    @Autowired
    private ILoginOrganizationService loginOrganizationService;

    @PutMapping("/update")
    @ApiOperation("修改机构")
    public CommonResult update(@RequestBody  LoginOrganizationQO loginOrganizationQO,HttpServletRequest request){
        LoginOrganization loginOrganization = new LoginOrganization();
        BeanUtils.copyProperties(loginOrganizationQO,loginOrganization);
        return loginOrganizationService.renewal(loginOrganization,request);
    }
    @PostMapping("/save")
    @ApiOperation("添加机构")
    public CommonResult save(@RequestBody  LoginOrganizationQO loginOrganizationQO,HttpServletRequest request){
        LoginOrganization loginOrganization = new LoginOrganization();
        BeanUtils.copyProperties(loginOrganizationQO,loginOrganization);
        return loginOrganizationService.create(loginOrganization,request);
    }

    @ApiOperation("查找机构")
    @GetMapping("/find")
    public CommonResult<IPage<LoginOrganizationVO>> find(@RequestBody LoginOrganizationQO loginOrganizationQO,HttpServletRequest request){
        LoginOrganization loginOrganization = new LoginOrganization();
        BeanUtils.copyProperties(loginOrganizationQO,loginOrganization);
        return loginOrganizationService.find(loginOrganization);
    }

    }
